<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class MY_Controller extends CI_Controller {

	function __construct() {
		parent::__construct();

	}

	protected function checkSubmit() {
		$submitToken = $this->input->post('submitToken');
		return isset($submitToken);
	}

	protected function response_json_width_msg($code, $msg, $values = array())
	{
		$result = $this->_get_response_result($code, $msg, $values);
		if (ErrorCode::SUCCESS !== $code) {
			Log::warning($code, array_merge($result, $this->input->post()));
		}
		$response_json = json_encode($result);
		Log::push_notice("response", $response_json);
		echo $response_json;
		exit();
	}

	private function _get_response_result($code, $msg, $values = array())
	{
		//国际化查找定义错误,没有定义,就用 $msg ,定义,以翻译为主.
		$defineMsg = $this->lang->line("error_code_" . $code, FALSE);
		if (!empty($defineMsg)) {
			$msg = $defineMsg;
		}

		if (empty($msg)) {
			$msg = '';
		}

		$result = array('ret' => $code, 'msg' => $msg);
		if (!empty($values)) {
			$result = array_merge($result, $values);
		}
		return $result;
	}


}

include "AdminBase.php";
